Bug 408154 – [PATCH] Change GtkEntryCompletion max-items to style
authorMatthias Clasen <mclasen@redhat.com>
Wed, 17 Sep 2008 15:22:52 +0000 (15:22 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 17 Sep 2008 15:22:52 +0000 (15:22 +0000)
2008-09-17  Matthias Clasen  <mclasen@redhat.com>

        Bug 408154 – [PATCH] Change GtkEntryCompletion max-items to style
        property

        * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup):
        Take actions into account when finding the available space for
        matches. Patch by Ross Burton

svn path=/trunk/; revision=21413

ChangeLog
gtk/gtkentrycompletion.c

index 4c52e8d6407721db34126dfcd823388d8d64745d..e0a9dbc678f7ac4baa7a31f41273aed61bd5419d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-17  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 408154 – [PATCH] Change GtkEntryCompletion max-items to style
+       property
+
+       * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): 
+       Take actions into account when finding the available space for
+       matches. Patch by Ross Burton
+
 2008-09-17  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 552500 – GtkPrintSettings API doc not precise enough
index e739f5f8a7794d98d1f72e8d9336c6c359fedf29..932637488a0a2b5dfc5a1e5a6e1a6f576a3a3732 100644 (file)
@@ -1365,7 +1365,7 @@ gboolean
 _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
 {
   gint x, y;
-  gint matches, items, height, x_border, y_border;
+  gint matches, actions, items, height, x_border, y_border;
   GdkScreen *screen;
   gint monitor_num;
   gint vertical_separator;
@@ -1383,6 +1383,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
   _gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
 
   matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
+  actions = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
 
   gtk_tree_view_column_cell_get_size (completion->priv->column, NULL,
                                       NULL, NULL, NULL, &height);
@@ -1403,9 +1404,9 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
   
 
   if (y > monitor.height / 2)
-    items = MIN (matches, (monitor.y + y) / height);
+    items = MIN (matches, (monitor.y + y) / height - actions);
   else
-    items = MIN (matches, (monitor.height - y) / height - 1);
+    items = MIN (matches, (monitor.height - y) / height - 1  - actions);
 
   if (items <= 0)
     gtk_widget_hide (completion->priv->scrolled_window);
@@ -1423,9 +1424,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
   /* default on no match */
   completion->priv->current_selected = -1;
 
-  items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->actions), NULL);
-
-  if (items)
+  if (actions)
     {
       gtk_widget_show (completion->priv->action_view);
       gtk_widget_set_size_request (completion->priv->action_view, width, -1);